package com.easylinkin.linkappapi.circuit.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easylinkin.linkappapi.circuit.dto.RailLinkappAiHostRecordDTO;
import com.easylinkin.linkappapi.circuit.entity.RailLinkappAiHostRecord;
import com.easylinkin.linkappapi.circuit.vo.RailLinkappAiHostRecordStatisticsVO;
import com.easylinkin.linkappapi.circuit.vo.RailLinkappAiHostRecordVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RailLinkappAiHostRecordMapper extends BaseMapper<RailLinkappAiHostRecord>{

    @Select("SELECT COUNT(1) FROM rail_linkapp_ai_host_record a WHERE a.tenant_id=#{tenantId} and a.ai_rule_type=#{aiRuleType} ")
    Integer selectByAiRuleTypeAndTenantId(@Param("tenantId")String tenantId,@Param("aiRuleType")String aiRuleType);

    /**
     * 统计当日数量
     */
    Long countTodayByTenantId(@Param("tenantId")String tenantId);

    /**
     * 统计近7日数量countLast7DaysByTenantId
     */
    Long countLast7DaysByTenantId(@Param("tenantId")String tenantId);

    List<RailLinkappAiHostRecordVO> getList(@Param("entity")RailLinkappAiHostRecordDTO dto);

    IPage<RailLinkappAiHostRecordVO> getList(Page page,@Param("entity") RailLinkappAiHostRecordDTO customQueryParams);

    RailLinkappAiHostRecordVO getNowByOne(@Param("tenantId") String tenantId, @Param("types") List<String> types);

    List<RailLinkappAiHostRecordVO> codeByNewRecords(@Param("tenantId") String tenantId, @Param("codes") List<String> codes);

   List<RailLinkappAiHostRecordStatisticsVO> countLastNumber7DaysByTenantId(@Param("tenantId")String tenantId,@Param("codes")List<String> codes);
    List<RailLinkappAiHostRecordStatisticsVO>  countLastNumber30DaysByTenantId(@Param("tenantId")String tenantId, @Param("codes")List<String> codes);

    RailLinkappAiHostRecordVO getNowHourByOne(@Param("tenantId") String tenantId, @Param("types") List<String> types);

    Integer getNowDayByOne(@Param("tenantId") String tenantId, @Param("types") List<String> types);

    List<RailLinkappAiHostRecordStatisticsVO> getNowDayByAll(@Param("tenantId") String tenantId);

    @Select("SELECT GROUP_CONCAT(DISTINCT(channel_name)  SEPARATOR ',') from  rail_linkapp_ai_host_record where tenant_id=#{tenantId}")
    String getNameGroupBy(@Param("tenantId")String tenantId);

    List<RailLinkappAiHostRecordStatisticsVO> countName7DaysByTenantId(@Param("tenantId")String tenantId,@Param("names")List<String> names);
    List<RailLinkappAiHostRecordStatisticsVO>  countName30DaysByTenantId(@Param("tenantId")String tenantId, @Param("names")List<String> names);



}
